package filter;

import javax.servlet.*;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletRequestWrapper;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.UnsupportedEncodingException;
import java.util.Map;

public class GenericEncodingFilter implements Filter {
    @Override
    public void init(FilterConfig filterConfig) throws ServletException {

    }

    @Override
    public void doFilter(ServletRequest request, ServletResponse response, FilterChain filterChain) throws IOException, ServletException {
//        //处理response的字符编码
//        HttpServletResponse myResponse=(HttpServletResponse) response;
//        myResponse.setContentType("text/html;charset=UTF-8");
//        // 转型为与协议相关对象
//        HttpServletRequest httpServletRequest = (HttpServletRequest) request;
//        // 对request包装增强
//        HttpServletRequest myrequest = new MyRequest(httpServletRequest);
//        chain.doFilter(myrequest, response);
    }

    @Override
    public void destroy() {

    }
}
